<template>
  <div>
    <div class="conheader">
      <el-image src="/huhehaote/images/headertitle.png" fit="fill"></el-image>
      <el-button
        circle
        class="el-icon-switch-button"
        size="default"
        @click="destroy"
      ></el-button>

      <el-dropdown :style="{ display: changetable }" size="primary">
        <el-button>
          切换桌面<i class="el-icon-arrow-down el-icon--right"></i>
        </el-button>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item @click.native="analysis">分析桌面</el-dropdown-item>
          <el-dropdown-item @click.native="work">工作桌面</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      changetable: "none",
      changeList: [{}],
    };
  },
  methods: {
    changeTable() {
      if (this.$route.params.power == 2) {
        this.changetable = "block";
      }
    },
    analysis() {
      this.$router
        .push({
          name: "analysis",
          params: {},
        })
        .catch((err) => {
          console.log(err);
        });
    },
    work() {
      this.$router
        .push({
          name: "sum-analysis",
          // params: {
          //   value:'sum-analysis'
          // },
        })
        .catch((err) => {
          console.log(err);
        });
    },
    destroy() {
      this.$confirm("是否注销当前账号?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {

          this.$http.get('/admin/logout').then((res) => {
            console.log(res);
             this.$router.push({
            name: "index",
          });
          }).catch((err) => {
            console.log(err);
          });
         
          this.$message({
            type: "success",
            message: "注销成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消",
          });
        });
    },
  },
  created() {
    this.changeTable();
  },
};
</script>

<style >
.conheader {
  position: relative;
  text-align: left;
  margin: 0px;
  background-image: linear-gradient(#223458, #0f4d83);
  box-shadow: 0px 3px 5px #888888;
}
.conheader .el-dropdown {
  width: 120px;
  float: right;
  right: 20px;
}
.conheader .el-button {
  float: right;
  margin-top: 8px;
  margin-right: 8px;
}
</style>